<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>水印设置</title>
    <style>
        /* 全局样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
            font-family: "PingFang SC", "Helvetica Neue", Arial, sans-serif;
        }
        
        body {
            background-color: #e9e9e9;
            color: #333;
            position: relative;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
        }
        
        /* 移动设备外壳 */
        .device-container {
            width: 360px;
            height: 720px;
            background-color: #111;
            border-radius: 40px;
            box-shadow: 0 10px 50px rgba(0,0,0,0.3);
            position: relative;
            overflow: hidden;
            border: 8px solid #222;
        }
        
        /* 设备状态栏 */
        .device-status-bar {
            height: 30px;
            background-color: #000;
            position: relative;
        }
        
        .device-status-bar:before {
            content: '';
            position: absolute;
            top: 10px;
            left: 50%;
            transform: translateX(-50%);
            width: 60px;
            height: 10px;
            background-color: #333;
            border-radius: 10px;
        }
        
        /* 设备屏幕内容 */
        .device-screen {
            height: calc(100% - 30px);
            width: 100%;
            background-color: #f8f8f8;
            overflow-y: auto;
            position: relative;
        }
        
        /* 底部导航键 */
        .device-nav-button {
            width: 50px;
            height: 5px;
            background-color: #444;
            border-radius: 3px;
            position: absolute;
            bottom: 10px;
            left: 50%;
            transform: translateX(-50%);
        }
        
        /* APP样式 */
        .header {
            background-color: #1976D2;
            color: white;
            padding: 16px;
            text-align: center;
            font-size: 18px;
            font-weight: bold;
            position: sticky;
            top: 0;
            left: 0;
            right: 0;
            z-index: 100;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        
        .preview-container {
            width: 100%;
            padding-top: 56.25%; /* 16:9比例 */
            position: relative;
            background-color: #000;
            overflow: hidden;
        }
        
        .preview-content {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            background-image: url('');
            background-size: cover;
        }
        
        .watermark {
            position: absolute;
            color: rgba(255, 255, 255, 0.7);
            font-size: 20px;
            font-weight: bold;
            text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
            padding: 5px;
            background-color: rgba(0, 0, 0, 0.2);
            border-radius: 4px;
            pointer-events: none; /* 防止在预览区域触发点击事件 */
        }
        
        .tab-container {
            width: 100%;
            overflow-x: auto;
            white-space: nowrap;
            background-color: white;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            position: relative;
        }
        
        .tabs {
            display: inline-flex;
            min-width: 100%;
        }
        
        .tab {
            padding: 14px 16px;
            text-align: center;
            cursor: pointer;
            transition: background-color 0.3s;
            color: #666;
            font-size: 14px;
            font-weight: 500;
            position: relative;
        }
        
        .tab.active {
            color: #1976D2;
            font-weight: bold;
        }
        
        .tab.active:after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 3px;
            background-color: #1976D2;
        }
        
        .tab-add {
            color: #1976D2;
            font-weight: bold;
        }
        
        .content-container {
            padding: 20px;
            background-color: white;
            margin-top: 10px;
            margin-bottom: 20px;
            border-radius: 8px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        .form-label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            font-size: 14px;
            color: #333;
        }
        
        .form-input {
            width: 100%;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 16px;
            background-color: #f9f9f9;
            color: #333;
        }
        
        .form-row {
            display: flex;
            margin: 0 -8px;
        }
        
        .form-col {
            flex: 1;
            padding: 0 8px;
        }
        
        .input-group {
            display: flex;
            align-items: center;
        }
        
        .input-addon {
            padding: 12px;
            background-color: #eee;
            color: #666;
            border: 1px solid #ddd;
            border-right: none;
            border-radius: 4px 0 0 4px;
            font-size: 16px;
        }
        
        .input-with-addon {
            border-radius: 0 4px 4px 0;
        }
        
        .btn {
            display: block;
            width: 100%;
            padding: 14px;
            background-color: #1976D2;
            color: white;
            border: none;
            border-radius: 4px;
            font-size: 16px;
            font-weight: 500;
            text-align: center;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        
        .btn:active {
            background-color: #1565C0;
        }
        
        /* 响应式适配 */
        @media (max-width: 400px) {
            .device-container {
                width: 100%;
                height: 100vh;
                border-radius: 0;
                border: none;
            }
        }
    </style>
</head>
<body>
    <!-- 移动设备外壳 -->
    <div class="device-container">
        <!-- 设备状态栏 -->
        <div class="device-status-bar"></div>
        
        <!-- 设备屏幕内容 -->
        <div class="device-screen">
            <!-- APP内容 -->
            <div class="header">水印设置</div>
            
            <!-- 预览区域 (16:9比例) -->
            <div class="preview-container">
                <div class="preview-content">
                    <div id="watermark-preview" class="watermark" style="top: 20px; left: 20px;">水印测试文本</div>
                </div>
            </div>
            
            <!-- 选项卡区域 -->
            <div class="tab-container">
                <div class="tabs" id="tabs">
                    <div class="tab active" data-id="1">水印</div>
                    <div class="tab" data-id="2">水印2</div>
                    <div class="tab" data-id="3">水印3</div>
                    <div class="tab tab-add" id="add-tab">添加</div>
                </div>
            </div>
            
            <!-- 设置内容区域 -->
            <div class="content-container">
                <div class="form-group">
                    <label class="form-label">字体大小</label>
                    <input type="range" min="10" max="50" value="20" class="form-input" id="font-size">
                    <div style="text-align: center; margin-top: 8px;"><span id="font-size-value">20</span>px</div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">位置</label>
                    <div class="form-row">
                        <div class="form-col">
                            <div class="input-group">
                                <span class="input-addon">X:</span>
                                <input type="number" min="0" max="100" value="20" class="form-input input-with-addon" id="position-x">
                            </div>
                        </div>
                        <div class="form-col">
                            <div class="input-group">
                                <span class="input-addon">Y:</span>
                                <input type="number" min="0" max="100" value="20" class="form-input input-with-addon" id="position-y">
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">水印文本</label>
                    <input type="text" value="水印测试文本" class="form-input" id="watermark-text">
                </div>
                
                <button class="btn">保存设置</button>
            </div>
        </div>
        
        <!-- 底部导航键 -->
        <div class="device-nav-button"></div>
    </div>
    
    <script>
        // 选项卡切换
        const tabs = document.querySelectorAll('.tab');
        const addTab = document.getElementById('add-tab');
        
        // 水印设置数据
        const watermarks = [
            { id: 1, text: "水印测试文本", fontSize: 20, posX: 20, posY: 20 },
            { id: 2, text: "水印2", fontSize: 24, posX: 50, posY: 50 },
            { id: 3, text: "水印3", fontSize: 16, posX: 70, posY: 70 }
        ];
        
        let currentTabId = 1;
        let nextTabId = 4;
        
        // 更新预览
        function updatePreview() {
            const watermark = watermarks.find(w => w.id === currentTabId);
            if (watermark) {
                const preview = document.getElementById('watermark-preview');
                preview.textContent = watermark.text;
                preview.style.fontSize = watermark.fontSize + 'px';
                preview.style.top = watermark.posY + 'px';
                preview.style.left = watermark.posX + 'px';
                
                // 更新表单值
                document.getElementById('font-size').value = watermark.fontSize;
                document.getElementById('font-size-value').textContent = watermark.fontSize;
                document.getElementById('position-x').value = watermark.posX;
                document.getElementById('position-y').value = watermark.posY;
                document.getElementById('watermark-text').value = watermark.text;
            }
        }
        
        // 切换选项卡
        function switchTab(tab) {
            tabs.forEach(t => t.classList.remove('active'));
            tab.classList.add('active');
            currentTabId = parseInt(tab.dataset.id);
            updatePreview();
        }
        
        // 点击选项卡事件
        tabs.forEach(tab => {
            if (!tab.classList.contains('tab-add')) {
                tab.addEventListener('click', () => {
                    switchTab(tab);
                });
            }
        });
        
        // 添加新选项卡
        addTab.addEventListener('click', () => {
            // 创建新选项卡
            const newTab = document.createElement('div');
            newTab.className = 'tab';
            newTab.dataset.id = nextTabId;
            newTab.textContent = '水印' + nextTabId;
            
            // 添加新水印数据
            watermarks.push({
                id: nextTabId,
                text: '水印' + nextTabId,
                fontSize: 20,
                posX: 20,
                posY: 20
            });
            
            // 添加点击事件
            newTab.addEventListener('click', () => {
                switchTab(newTab);
            });
            
            // 插入到添加按钮前面
            document.getElementById('tabs').insertBefore(newTab, addTab);
            
            // 自动切换到新选项卡
            switchTab(newTab);
            
            // 更新下一个ID
            nextTabId++;
        });
        
        // 表单更改事件
        document.getElementById('font-size').addEventListener('input', function() {
            const value = parseInt(this.value);
            document.getElementById('font-size-value').textContent = value;
            
            // 更新数据和预览
            const watermark = watermarks.find(w => w.id === currentTabId);
            if (watermark) {
                watermark.fontSize = value;
                document.getElementById('watermark-preview').style.fontSize = value + 'px';
            }
        });
        
        document.getElementById('position-x').addEventListener('input', function() {
            const value = parseInt(this.value);
            
            // 更新数据和预览
            const watermark = watermarks.find(w => w.id === currentTabId);
            if (watermark) {
                watermark.posX = value;
                document.getElementById('watermark-preview').style.left = value + 'px';
            }
        });
        
        document.getElementById('position-y').addEventListener('input', function() {
            const value = parseInt(this.value);
            
            // 更新数据和预览
            const watermark = watermarks.find(w => w.id === currentTabId);
            if (watermark) {
                watermark.posY = value;
                document.getElementById('watermark-preview').style.top = value + 'px';
            }
        });
        
        document.getElementById('watermark-text').addEventListener('input', function() {
            const value = this.value;
            
            // 更新数据和预览
            const watermark = watermarks.find(w => w.id === currentTabId);
            if (watermark) {
                watermark.text = value;
                document.getElementById('watermark-preview').textContent = value;
            }
        });
        
        // 初始化预览
        updatePreview();
    </script>
</body>
</html> 